package com.test.demo;

import java.util.Calendar;
import java.util.Scanner;

public class YearMonthDay {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int dayArr[] = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

        System.out.println("请输入年份");
        int year = scanner.nextInt();
        System.out.println("请输入月份");
        int month = scanner.nextInt();
        System.out.println("请输入日期");
        int day = scanner.nextInt();
        int count = 0;//存放指定月份前面几个月的总天数
        int days = 0;//用于记录每个月的总天数
        for (int i = 1; i < month; i++) {
            switch (i) {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    days = 31;
                    break;
                case 4:
                case 6:
                case 9:
                case 11:
                    days = 30;
                    break;
                case 2:
                    //闰年条件
                    if((year%100!=0&&year%4==0)||(year%100==0&&year%400==0)){
                        days=29;
                    }else {
                        days=28;
                    }
                    break;
            }
            count+=days;
        }
        System.out.println(year+"年"+month+"月"+day+"日是当年的第"+(count+day)+"天");
    }

}
